home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Developer & Web Development Tools / Inno Setup 5.2.3 / isetup-5.2.3.exe / {app} / Examples / CodeClasses.iss (.txt) < prev    next >
Encoding:
Inno Setup Script  |  2008-03-08  |  11.1 KB  |  256 lines

  1. ; -- CodeClasses.iss --
  2. ; This script shows how to use the WizardForm object and the various VCL classes.
  3. [Setup]
  4. AppName=My Program
  5. AppVerName=My Program version 1.5
  6. CreateAppDir=no
  7. DisableProgramGroupPage=yes
  8. DefaultGroupName=My Program
  9. UninstallDisplayIcon={app}\MyProg.exe
  10. WindowVisible=yes
  11. OutputDir=userdocs:Inno Setup Examples Output
  12. [Files]
  13. Source: compiler:WizModernSmallImage.bmp; Flags: dontcopy
  14. [Code]
  15. procedure ButtonOnClick(Sender: TObject);
  16. begin
  17.   MsgBox('You clicked the button!', mbInformation, mb_Ok);
  18. procedure FormButtonOnClick(Sender: TObject);
  19.   Form: TSetupForm;
  20.   OKButton, CancelButton: TNewButton;
  21. begin
  22.   Form := CreateCustomForm();
  23.   try
  24.     Form.ClientWidth := ScaleX(256);
  25.     Form.ClientHeight := ScaleY(256);
  26.     Form.Caption := 'TSetupForm';
  27.     Form.CenterInsideControl(WizardForm, False);
  28.     OKButton := TNewButton.Create(Form);
  29.     OKButton.Parent := Form;
  30.     OKButton.Width := ScaleX(75);
  31.     OKButton.Height := ScaleY(23);
  32.     OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
  33.     OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  34.     OKButton.Caption := 'OK';
  35.     OKButton.ModalResult := mrOk;
  36.     CancelButton := TNewButton.Create(Form);
  37.     CancelButton.Parent := Form;
  38.     CancelButton.Width := ScaleX(75);
  39.     CancelButton.Height := ScaleY(23);
  40.     CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
  41.     CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  42.     CancelButton.Caption := 'Cancel';
  43.     CancelButton.ModalResult := mrCancel;
  44.     CancelButton.Cancel := True;
  45.     Form.ActiveControl := OKButton;
  46.     if Form.ShowModal() = mrOk then
  47.       MsgBox('You clicked OK.', mbInformation, MB_OK);
  48.   finally
  49.     Form.Free();
  50.   end;
  51. procedure CreateTheWizardPages;
  52.   Page: TWizardPage;
  53.   Button, FormButton: TNewButton;
  54.   CheckBox: TNewCheckBox;
  55.   Edit: TNewEdit;
  56.   PasswordEdit: TPasswordEdit;
  57.   Memo: TNewMemo;
  58.   ComboBox: TNewComboBox;
  59.   ListBox: TNewListBox;
  60.   StaticText, ProgressBarLabel: TNewStaticText;
  61.   ProgressBar: TNewProgressBar;
  62.   CheckListBox, CheckListBox2: TNewCheckListBox;
  63.   FolderTreeView: TFolderTreeView;
  64.   BitmapImage, BitmapImage2, BitmapImage3: TBitmapImage;
  65.   BitmapFileName: String;
  66.   RichEditViewer: TRichEditViewer;
  67. begin
  68.   { TButton and others }
  69.   Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TButton and others');
  70.   Button := TNewButton.Create(Page);
  71.   Button.Width := ScaleX(75);
  72.   Button.Height := ScaleY(23);
  73.   Button.Caption := 'TNewButton';
  74.   Button.OnClick := @ButtonOnClick;
  75.   Button.Parent := Page.Surface;
  76.   CheckBox := TNewCheckBox.Create(Page);
  77.   CheckBox.Top := Button.Top + Button.Height + ScaleY(8);
  78.   CheckBox.Width := Page.SurfaceWidth;
  79.   CheckBox.Height := ScaleY(17);
  80.   CheckBox.Caption := 'TNewCheckBox';
  81.   CheckBox.Checked := True;
  82.   CheckBox.Parent := Page.Surface;
  83.   Edit := TNewEdit.Create(Page);
  84.   Edit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  85.   Edit.Width := Page.SurfaceWidth div 2 - ScaleX(8);
  86.   Edit.Text := 'TNewEdit';
  87.   Edit.Parent := Page.Surface;
  88.   PasswordEdit := TPasswordEdit.Create(Page);
  89.   PasswordEdit.Left := Page.SurfaceWidth - Edit.Width;
  90.   PasswordEdit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  91.   PasswordEdit.Width := Edit.Width;
  92.   PasswordEdit.Text := 'TPasswordEdit';
  93.   PasswordEdit.Parent := Page.Surface;
  94.   Memo := TNewMemo.Create(Page);
  95.   Memo.Top := Edit.Top + Edit.Height + ScaleY(8);
  96.   Memo.Width := Page.SurfaceWidth;
  97.   Memo.Height := ScaleY(89);
  98.   Memo.ScrollBars := ssVertical;
  99.   Memo.Text := 'TNewMemo';
  100.   Memo.Parent := Page.Surface;
  101.   FormButton := TNewButton.Create(Page);
  102.   FormButton.Top := Memo.Top + Memo.Height + ScaleY(8);
  103.   FormButton.Width := ScaleX(75);
  104.   FormButton.Height := ScaleY(23);
  105.   FormButton.Caption := 'TSetupForm';
  106.   FormButton.OnClick := @FormButtonOnClick;
  107.   FormButton.Parent := Page.Surface;
  108.   { TComboBox and others }
  109.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TComboBox and others');
  110.   ComboBox := TNewComboBox.Create(Page);
  111.   ComboBox.Width := Page.SurfaceWidth;
  112.   ComboBox.Parent := Page.Surface;
  113.   ComboBox.Style := csDropDownList;
  114.   ComboBox.Items.Add('TComboBox');
  115.   ComboBox.ItemIndex := 0;
  116.   ListBox := TNewListBox.Create(Page);
  117.   ListBox.Top := ComboBox.Top + ComboBox.Height + ScaleY(8);
  118.   ListBox.Width := Page.SurfaceWidth;
  119.   ListBox.Height := ScaleY(97);
  120.   ListBox.Parent := Page.Surface;
  121.   ListBox.Items.Add('TListBox');
  122.   ListBox.ItemIndex := 0;
  123.   StaticText := TNewStaticText.Create(Page);
  124.   StaticText.Top := ListBox.Top + ListBox.Height + ScaleY(8);
  125.   StaticText.Caption := 'TNewStaticText';
  126.   StaticText.AutoSize := True;
  127.   StaticText.Parent := Page.Surface;
  128.   ProgressBarLabel := TNewStaticText.Create(Page);
  129.   ProgressBarLabel.Top := StaticText.Top + StaticText.Height + ScaleY(8);
  130.   ProgressBarLabel.Caption := 'TNewProgressBar';
  131.   ProgressBarLabel.AutoSize := True;
  132.   ProgressBarLabel.Parent := Page.Surface;
  133.   ProgressBar := TNewProgressBar.Create(Page);
  134.   ProgressBar.Left := ProgressBarLabel.Width + ScaleX(8);
  135.   ProgressBar.Top := ProgressBarLabel.Top;
  136.   ProgressBar.Width := Page.SurfaceWidth - ProgressBar.Left;
  137.   ProgressBar.Height := ProgressBarLabel.Height + ScaleY(8);
  138.   ProgressBar.Parent := Page.Surface;
  139.   ProgressBar.Position := 25;
  140.   { TNewCheckListBox }
  141.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TNewCheckListBox');
  142.   CheckListBox := TNewCheckListBox.Create(Page);
  143.   CheckListBox.Width := Page.SurfaceWidth;
  144.   CheckListBox.Height := ScaleY(97);
  145.   CheckListBox.Flat := True;
  146.   CheckListBox.Parent := Page.Surface;
  147.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  148.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, True, True, nil);
  149.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, False, True, nil);
  150.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  151.   CheckListBox2 := TNewCheckListBox.Create(Page);
  152.   CheckListBox2.Top := CheckListBox.Top + CheckListBox.Height + ScaleY(8);
  153.   CheckListBox2.Width := Page.SurfaceWidth;
  154.   CheckListBox2.Height := ScaleY(97);
  155.   CheckListBox2.BorderStyle := bsNone;
  156.   CheckListBox2.ParentColor := True;
  157.   CheckListBox2.MinItemHeight := WizardForm.TasksList.MinItemHeight;
  158.   CheckListBox2.ShowLines := False;
  159.   CheckListBox2.WantTabs := True;
  160.   CheckListBox2.Parent := Page.Surface;
  161.   CheckListBox2.AddGroup('TNewCheckListBox', '', 0, nil);
  162.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, True, True, nil);
  163.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, False, True, nil);
  164.   { TFolderTreeView }
  165.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TFolderTreeView');
  166.   FolderTreeView := TFolderTreeView.Create(Page);
  167.   FolderTreeView.Width := Page.SurfaceWidth;
  168.   FolderTreeView.Height := Page.SurfaceHeight;
  169.   FolderTreeView.Parent := Page.Surface;
  170.   FolderTreeView.Directory := ExpandConstant('{src}');
  171.   { TBitmapImage }
  172.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TBitmapImage');
  173.   BitmapFileName := ExpandConstant('{tmp}\WizModernSmallImage.bmp');
  174.   ExtractTemporaryFile(ExtractFileName(BitmapFileName));
  175.   BitmapImage := TBitmapImage.Create(Page);
  176.   BitmapImage.AutoSize := True;
  177.   BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
  178.   BitmapImage.Parent := Page.Surface;
  179.   BitmapImage2 := TBitmapImage.Create(Page);
  180.   BitmapImage2.BackColor := $400000;
  181.   BitmapImage2.Bitmap := BitmapImage.Bitmap;
  182.   BitmapImage2.Center := True;
  183.   BitmapImage2.Left := BitmapImage.Width + 10;
  184.   BitmapImage2.Height := 2*BitmapImage.Height;
  185.   BitmapImage2.Width := 2*BitmapImage.Width;
  186.   BitmapImage2.Parent := Page.Surface;
  187.   BitmapImage3 := TBitmapImage.Create(Page);
  188.   BitmapImage3.Bitmap := BitmapImage.Bitmap;
  189.   BitmapImage3.Stretch := True;
  190.   BitmapImage3.Left := 3*BitmapImage.Width + 20;
  191.   BitmapImage3.Height := 4*BitmapImage.Height;
  192.   BitmapImage3.Width := 4*BitmapImage.Width;
  193.   BitmapImage3.Parent := Page.Surface;
  194.   { TRichViewer }
  195.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TRichViewer');
  196.   RichEditViewer := TRichEditViewer.Create(Page);
  197.   RichEditViewer.Width := Page.SurfaceWidth;
  198.   RichEditViewer.Height := Page.SurfaceHeight;
  199.   RichEditViewer.Parent := Page.Surface;
  200.   RichEditViewer.ScrollBars := ssVertical;
  201.   RichEditViewer.UseRichEdit := True;
  202.   RichEditViewer.RTFText := '{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue128;}\viewkind4\uc1\pard\f0\fs20 T\cf1 Rich\cf2 Edit\cf3 Viewer\cf0\par}';
  203.   RichEditViewer.ReadOnly := True;
  204. procedure AboutButtonOnClick(Sender: TObject);
  205. begin
  206.   MsgBox('This demo shows some features of the various form objects and control classes.', mbInformation, mb_Ok);
  207. procedure URLLabelOnClick(Sender: TObject);
  208.   ErrorCode: Integer;
  209. begin
  210.   ShellExec('open', 'http://www.innosetup.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
  211. procedure CreateAboutButtonAndURLLabel(ParentForm: TSetupForm; CancelButton: TNewButton);
  212.   AboutButton: TNewButton;
  213.   URLLabel: TNewStaticText;
  214. begin
  215.   AboutButton := TNewButton.Create(ParentForm);
  216.   AboutButton.Left := ParentForm.ClientWidth - CancelButton.Left - CancelButton.Width;
  217.   AboutButton.Top := CancelButton.Top;
  218.   AboutButton.Width := CancelButton.Width;
  219.   AboutButton.Height := CancelButton.Height;
  220.   AboutButton.Caption := '&About...';
  221.   AboutButton.OnClick := @AboutButtonOnClick;
  222.   AboutButton.Parent := ParentForm;
  223.   URLLabel := TNewStaticText.Create(ParentForm);
  224.   URLLabel.Caption := 'www.innosetup.com';
  225.   URLLabel.Cursor := crHand;
  226.   URLLabel.OnClick := @URLLabelOnClick;
  227.   URLLabel.Parent := ParentForm;
  228.   { Alter Font *after* setting Parent so the correct defaults are inherited first }
  229.   URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
  230.   URLLabel.Font.Color := clBlue;
  231.   URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
  232.   URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
  233. procedure InitializeWizard();
  234.   BackgroundBitmapImage: TBitmapImage;
  235.   BackgroundBitmapText: TNewStaticText;
  236. begin
  237.   { Custom wizard pages }
  238.   CreateTheWizardPages;
  239.   { Custom controls }
  240.   CreateAboutButtonAndURLLabel(WizardForm, WizardForm.CancelButton);
  241.   BackgroundBitmapImage := TBitmapImage.Create(MainForm);
  242.   BackgroundBitmapImage.Left := 50;
  243.   BackgroundBitmapImage.Top := 90;
  244.   BackgroundBitmapImage.AutoSize := True;
  245.   BackgroundBitmapImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
  246.   BackgroundBitmapImage.Parent := MainForm;
  247.   BackgroundBitmapText := TNewStaticText.Create(MainForm);
  248.   BackgroundBitmapText.Left := BackgroundBitmapImage.Left;
  249.   BackgroundBitmapText.Top := BackgroundBitmapImage.Top + BackgroundBitmapImage.Height + ScaleY(8);
  250.   BackgroundBitmapText.Caption := 'TBitmapImage';
  251.   BackgroundBitmapText.Parent := MainForm;
  252. procedure InitializeUninstallProgressForm();
  253. begin
  254.   { Custom controls }
  255.   CreateAboutButtonAndURLLabel(UninstallProgressForm, UninstallProgressForm.CancelButton);
  256.